//
//  UIBarButtonItem+Extension.swift
//  新浪微博
//
//  Created by jie peng on 16/5/19.
//  Copyright © 2016年 jie peng. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    convenience init(imageName: String,title: String? = nil,target: AnyObject?, action: Selector){
        self.init()
        
        let btn = UIButton()
        
        btn.setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        btn.setImage(UIImage(named: imageName), forState: .Normal)
        
        btn.setTitleColor(UIColor.grayColor(), forState: .Normal)
        btn.setTitleColor(UIColor.orangeColor(), forState: .Highlighted)
        
        btn.setTitle(title, forState: .Normal)
        btn.sizeToFit()
        btn.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        
        
        self.customView = btn
        
    }

}